#ifndef SERVER_H
#define SERVER_H

#include <QObject>
#include <QUrl>

class Server : public QObject
{
    Q_OBJECT

public:
    /**
     * @brief Value of ping() if server is unavailable.
     */
    static const int HOST_UNAVAILABLE = -1;

    explicit Server( int id, QObject *parent = NULL );

    /**
     * @return Check stats.
     */
    bool checkStats() const;

    /**
     * @return The server load of last minute.
     */
    float loadOne() const;

    /**
     * @return The server load of last five minutes.
     */
    float loadFive() const;

    /**
     * @return The server load of last fifteen minutes.
     */
    float loadFifteen() const;

    /**
     * @return The max server load of last minute.
     */
    float maxLoadOne() const;

    /**
     * @return The max server load of last five minutes.
     */
    float maxLoadFive() const;

    /**
     * @return The max server load of last fifteen minutes.
     */
    float maxLoadFifteen() const;

    /**
     * @return The server max ping.
     */
    int maxPing() const;
    
    /**
     * @return The server name.
     */
    QString name() const;

    /**
     * @return The server ping. A positive value or value HOST_UNAVAILABLE
     *         if host not available
     */
    int ping() const;

    /**
     * @param check Check stats.
     */
    void setCheckStats( bool check );

    /**
     * @param value The server load of last minute.
     */
    void setLoadOne( float value );

    /**
     * @param value The server load of last five minutes.
     */
    void setLoadFive( float value );

    /**
     * @param value The server load of last fifteen minutes.
     */
    void setLoadFifteen( float value );

    /**
     * @param value The max server load of last minute.
     */
    void setMaxLoadOne( float value );

    /**
     * @param value The max server load of last five minutes.
     */
    void setMaxLoadFive( float value );

    /**
     * @param value The max server load of last fifteen minutes.
     */
    void setMaxLoadFifteen( float value );

    /**
     * @param ping The server max ping.
     */
    void setMaxPing( int ping );

    /**
     * @param name The server name.
     */
    void setName( const QString &name );

    /**
     * @param ping The server ping. A positive value or value
     *             HOST_UNAVAILABLE if host not available
     */
    void setPing( int ping );

    /**
     * @param url The server url.
     */
    void setUrl( const QUrl &url );

    /**
     * @return The server url.
     */
    QUrl url() const;

signals:
    /**
     * @brief Emitted if data has changed.
     * @param int Id of the server.
     */
    void dataChanged( int );
    
public slots:

private:
    bool mCheckStats;
    float mLoad1;
    float mLoad5;
    float mLoad15;
    int mId;
    QString mName;
    float mMaxLoad1;
    float mMaxLoad5;
    float mMaxLoad15;
    int mMaxPing;
    int mPing;
    QUrl mUrl;
};

#endif // SERVER_H
